package com.itheima_01.day04;

public class ArrayDemo {
    public static void main(String[] args) {
      /*  int[] arr = new int[2];
        int[] arr2=new int[3];
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr2);
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);

        arr[0] = 100;
        arr2[2] = 200;
        arr2[0]=100;
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr2);
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);
*/

        /*
        //索引越界 和 空指针错误
        int[] arr = new int[3];
        //System.out.println(arr[3]);
        arr = null;
        System.out.println(arr[0]);*/

        // 遍历数组内容
        int[] arr = {12, 12, 45, 78, 45, 152, 45, 54};
        int max = arr[0];
        int min = arr[0];
        for (int x = 1; x < arr.length; x++) {
            if (arr[x] > max) {
                max = arr[x];
            }
        }
        for (int x = 1; x < arr.length; x++) {
            if (arr[x] < min) {
                min = arr[x];
            }
        }
        System.out.println("max:" + max);
        System.out.println("min" + min);



    }
}
